/*
 * @Author: your name
 * @Date: 2019-11-29 17:08:07
 * @LastEditTime: 2019-12-12 19:14:20
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \福路德信息化平台APP\script\formConfigReportToSelf.js
 */
var reportToSelfPageConfig = function () {
    return {
        intoSelf(row, cell, callback) {
            var name = cell.url;
            var url = '';
            var pageParam = {};
            if (cell.Param) {
                var paramArray = cell.Param.split('&');
                for (var i in paramArray) {
                    var detailArray = paramArray[i].split('=');
                    pageParam[detailArray[0]] = row[detailArray[1].replace(/{/g, '').replace(/}/g, '')];
                }
            } else {
                pageParam = null;
            }
            if (name == '账户明细') {

                url = '../accountDetail.html';
                api.openWin({
                    name: 'accountDetail',
                    url: url,
                    reload: true,
                    slidBackEnabled: false,
                    pageParam: pageParam
                })

            } else if (name == '查看表单') {
                if (pageParam.S_BillType == 101 || pageParam.S_BillType == 1101 || pageParam.S_BillType == 401) {
                    FLD.ajax('AP_HisList_XX', pageParam, function (res) {
                        if (res.ds.length) {
                            var row = res.ds[0];
                            if (pageParam.S_BillType == 101 || pageParam.S_BillType == 1101) {
                                if (row.B_Type == 3) {
                                    api.openWin({
                                        name: 'sellingPrint',
                                        url: '../sellingPrint.html',
                                        reload: true,
                                        slidBackEnabled: false,
                                        pageParam: {
                                            historyData: row
                                        }
                                    })
                                } else {
                                    api.openWin({
                                        name: 'selling',
                                        url: '../selling.html',
                                        reload: true,
                                        slidBackEnabled: false,
                                        pageParam: {
                                            historyData: row
                                        }
                                    })
                                }
                            } else if (pageParam.S_BillType == 401) {
                                api.openWin({
                                    name: 'receipt',
                                    url: '../receipt.html',
                                    reload: true,
                                    slidBackEnabled: false,
                                    pageParam: {
                                        historyData: row
                                    }
                                })
                            }
                        }
                    })
                } else {
                    FLD.ajax('APP_BillLinkN', pageParam, function (res) {
                        
                        if (res.ds.length) {
                            api.openWin({
                                name: 'formConfig',
                                url: 'formConfig.html',
                                reload: true,
                                slidBackEnabled: false,
                                pageParam: {
                                    keyName: res.ds[0].B_KeyCol,
                                    keyValue: pageParam.S_BillID,
                                    objName: res.ds[0].APPListName,
                                    titleName: res.ds[0].BillName
                                    // isPosted: true
                                }
                            })
                        }
                    })
                }

            }else if(name == '应收账款明细'){
                var obj = {
                    S_BranchID:row.BranchID,
                    S_ClientID:row.ClientID,
                    name:row.BHName
                }
                api.openWin({
                    name: 'payment',
                    url: '../payment.html',
                    reload: true,
                    slidBackEnabled: false,
                    pageParam: obj
                })
            }else if(name == '查看详情'){
                api.openWin({
                    name: 'customersDetail1',
                    url: '../customersDetail1.html',
                    reload: true,
                    slidBackEnabled: false,
                    pageParam: {
                        id:row.ClientID,
                        name:row.BHName
                    }
                })
            }else if(name == '往来对账单'){
                // alert(JSON.stringify(row))
                api.openWin({
                    name: 'accountsReceivableList2',
                    url: '../accountsReceivableList2.html',
                    reload: true,
                    slidBackEnabled: false,
                    pageParam: {
                        titleName:name,
                        ClientID:row.ClientID,
                        ClientName:row.BHName,
                        BranchID:row.S_BranchID,
                        BranchName:row.BranchName,
                    }
                })
            }else{
                callback();
            }
        }
    }
}()